#pragma once
#include "DIndexBuffer.h"
#include "../DVector3.h"

namespace Skill
{
	namespace Ode
	{	
		namespace Geometries
		{			
			void DTriangle::CollectManagedMemory()
			{			
			}

			void DIndexBuffer::CollectManagedMemory()
			{						
			}

			int DIndexBuffer::IndexCount::get()
			{
				return triangleCount * 3;
			}

			int DIndexBuffer::TriangleStride::get()
			{
				return 12;
			}

			int DIndexBuffer::TriangleCount::get()
			{
				return triangleCount;
			}

			void DIndexBuffer::SetData(array<unsigned int>^ data,int startIndex,int lenght)
			{
				Marshal::Copy((array<int>^)data,startIndex,UnmanagedPointer,lenght);
			}
			void DIndexBuffer::SetData(array<unsigned int>^ data)
			{
				SetData(data,0,data->Length);
			}			
			void DIndexBuffer::SetTriangle(int triangleIndex,unsigned int a,unsigned int b,unsigned int c)
			{
				unsigned int* p = _This + 3 * triangleIndex;
				p[0] = a;
				p[1] = b;
				p[2] = c;
			}
			void DIndexBuffer::SetTriangle(int triangleIndex,DTriangle^ t)
			{
				unsigned int* p = _This + 3 * triangleIndex;
				p[0] = t->_This[0];
				p[1] = t->_This[1];
				p[2] = t->_This[2];
			}

			DTriangle^ DIndexBuffer::GetReferenceTriangle(int triangleIndex)
			{								
				unsigned int* p = _This + 3 * triangleIndex;
				return gcnew DTriangle(p);							
			}

		}
	}
}